<template>
    <!-- 商品组 -->
    <view class="diy-goods" :style="'background: ' + itemStyle.background + ';'">
        <view :class="'goods-list display__' + itemStyle.display + ' column__' + itemStyle.column">
            <scroll-view :scroll-x="itemStyle.display === 'slide'">
                <view class="goods-item" v-for="(dataItem, index) in dataList" :key="index">
                        <view @click="_onTargetGoods" class="btn-normal" :data-id="dataItem.goods_id">
                            <!-- 单列商品 -->
                            <block v-if="itemStyle.column == 1">
                                <view class="dis-flex">
                                    <!-- 商品图片 -->
                                    <view class="goods-item_left">
                                        <image class="image" :src="dataItem.image"></image>
                                    </view>
                                    <view class="goods-item_right">
                                        <!-- 商品名称 -->
                                        <view v-if="itemStyle.show.goodsName" class="goods-item_title twolist-hidden">
                                            <text>{{ dataItem.goods_name }}</text>
                                        </view>
                                        <view class="goods-item_desc">
                                            <!-- 商品卖点 -->
                                            <view v-if="itemStyle.show.sellingPoint" class="desc-selling_point dis-flex">
                                                <text class="onelist-hidden">{{ dataItem.selling_point }}</text>
                                            </view>
                                            <!-- 商品销量 -->
                                            <view v-if="itemStyle.show.goodsSales" class="desc-goods_sales dis-flex">
                                                <text>{{$t('m.yishou')}}{{ dataItem.goods_sales }}{{$t('m.jian')}}</text>
                                            </view>
                                            <!-- 商品价格 -->
                                            <view class="desc_footer">
                                                <text v-if="itemStyle.show.goodsPrice" class="price_x">¥{{ dataItem.goods_price }}</text>
                                                <text class="price_y col-9" v-if="itemStyle.show.linePrice && dataItem.line_price > 0">¥{{ dataItem.line_price }}</text>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </block>
                            <!-- 多列商品 -->
                            <block v-else>
                                <!-- 商品图片 -->
                                <view class="goods-image">
                                    <image class="image" mode="aspectFill" :src="dataItem.image"></image>
                                </view>
                                <view class="detail">
                                    <!-- 商品标题 -->
                                    <view v-if="itemStyle.show.goodsName" class="goods-name f-28 twolist-hidden">
                                        {{ dataItem.goods_name }}
                                    </view>
                                    <!-- 商品价格 -->
                                    <view class="detail-price onelist-hidden">
                                        <text v-if="itemStyle.show.goodsPrice" class="goods-price f-30 col-m">￥{{ dataItem.goods_price }}</text>
                                        <text v-if="itemStyle.show.linePrice && dataItem.line_price > 0" class="line-price col-9 f-24">￥{{ dataItem.line_price }}</text>
                                    </view>
                                </view>
                            </block>
						</view>	
                </view>
            </scroll-view>
        </view>
    </view>
</template>

<script>
const app = getApp();
export default {
    data() {
        return {
            dataItem: {
                goods_id: '',
                image: '',
                goods_name: '',
                selling_point: '',
                goods_sales: '',
                goods_price: '',
                line_price: 0
            }
        };
    },
    options: {
        addGlobalClass: true
    },
    /**
     * 组件的属性列表
     * 用于组件自定义设置
     */
    props: {
        itemIndex: String,
        itemStyle: Object,
        params: Object,
        dataList: Array
    },
    /**
     * 组件的方法列表
     * 更新属性和数据的方法与更新页面数据的方法类似
     */
    methods: {
        /**
         * 跳转商品详情页
         */
        _onTargetGoods(e) {
			console.log(e,'22222');
            // 记录formid
            uni.navigateTo({
                url: '/pages/goods/index?goods_id=' + e.currentTarget.dataset.id
            });
        }
    }
};
</script>
<style>
@import './goods.css';
</style>
